package com.ffcs.cn.action.desktopcontrol.smlabelhelpcontrol;

import com.supermap.desktop.controls.ui.controls.SmDialog;
import com.supermap.desktop.controls.ui.controls.labels.SmLabelHelp;
import com.supermap.desktop.core.Interface.helps.implement.DefaultHelpProvider;
import com.supermap.desktop.core.ui.controls.GridBagConstraintsHelper;
import com.supermap.desktop.core.utilties.CoreResources;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;

import java.awt.*;


public class DialogSmLabelHelp extends SmDialog {
	private SmLabelHelp labelHelp;

	public DialogSmLabelHelp() {
		setTitle("带有帮助提示信息的Label");
		setSize(new Dimension(300, 100));
		initComponents();
		initLayout();
	}

	private void initComponents() {
		// 帮助图标
		ResizableIcon icon = CoreResources.getHelpIcon()
				.setDimension(new Dimension(16, 16));
		// 帮助提供类
		DefaultHelpProvider helpProvider = new DefaultHelpProvider();
		// 设置帮助提示的标题
		helpProvider.setHelpTitle("帮助标题");
		// 设置帮助提示的图标
		helpProvider.setHelpImage(icon);
		// 设置帮助提示的链接信息
		helpProvider.setHelpText("这里是帮助具体信息的描述");
		labelHelp = new SmLabelHelp(helpProvider);
		labelHelp.setIcon(icon);
		labelHelp.setText("帮助");

	}

	private void initLayout() {
		this.setLayout(new GridBagLayout());
		this.add(labelHelp, new GridBagConstraintsHelper(0, 0, 1, 1)
				.setInsets(GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setWeight(1, 1)
				.setFill(GridBagConstraints.BOTH));
	}
}
